const routes = [
  { path: '/login', component: '@/pages/Login', breadTitle: '登录' },
  { path: '/register', component: '@/pages/Register', breadTitle: '注册' },
  {
    path: '/',
    extra: true,
    component: '@/layouts/Admin',
    breadTitle: '',
    wrappers: ['@/containers/Authentication'],
    routes: [
      { path: '/', redirect: '/dashboard' },
      {
        path: '/dashboard',
        component: '@/pages/Dashboard',
        breadTitle: '控制台',
        title: '控制台',
        wrappers: ['@/containers/Authorization'],
      },
      {
        path: '/user',
        breadTitle: '用户管理',
        title: '用户管理',
        component: '@/pages/System/UserManage',
        wrappers: ['@/containers/Authorization'],
      },
      {
        path: '/auth',
        breadTitle: '系统权限管理',
        title: '系统权限管理',
        component: '@/pages/System/SystemAuthManage',
        wrappers: ['@/containers/Authorization'],
      },
      {
        path: '/role',
        breadTitle: '角色管理',
        title: '角色管理',
        component: '@/pages/System/RoleManage',
        wrappers: ['@/containers/Authorization'],
      },
      { path: '/403', component: '@/pages/Forbidden' },
      { component: '@/pages/NotFound' },
    ],
  },
  { component: '@/pages/NotFound' },
];
const setTitle = (list) => {
  return list.map((item) => {
    if (item.title || !item.breadTitle) return item;
    item.title = item.breadTitle;
    if (item.children && item.children.length) {
      item.children = setTitle(item.children);
    }
    return item;
  });
};

export default setTitle(routes);
